/**
*   @file    Mcu_LPU_Types.h
*   @version 1.0.0
*
*   @brief   AUTOSAR Mcu - Exported data outside of the Mcu from SRC.
*   @details Public data types exported outside of the Mcu driver.
*
*   @addtogroup MCU
*   @{
*/
/*==================================================================================================
*   Project              : AUTOSAR 4.2 MCAL
*   Platform             : PA
*   Peripheral           : MC
*   Dependencies         : none
*
*   Autosar Version      : 4.2.2
*   Autosar Revision     : ASR_REL_4_2_REV_0002
*   Autosar Conf.Variant :
*   SW Version           : 1.0.0
*   Build Version        : MPC574XG_MCAL_1_0_0_RTM_ASR_REL_4_2_REV_0002_20170217
*
*   (c) Copyright 2006-2016 Freescale Semiconductor, Inc. 
*       Copyright 2017 NXP
*   All Rights Reserved.
==================================================================================================*/
/*==================================================================================================
==================================================================================================*/


#ifndef MCU_LPU_TYPES_H
#define MCU_LPU_TYPES_H

#ifdef __cplusplus
extern "C"{
#endif


/**
* @page misra_violations MISRA-C:2004 violations
*
* @section MCU_LPU_TYPES_h_REF_1
* Violates MISRA 2004 Advisory Rule 19.7, Function-like macro defined
* This violation is due to function like macros defined for register operations.
* Function like macros are used to reduce code complexity.
*
* @section [global]
* Violates MISRA 2004 Required Rule 5.1, Identifiers (internal and external) shall not rely
* on the significance of more than 31 characters. The used compilers use more than 31 chars for
* identifiers.
*/


/*==================================================================================================
                                         INCLUDE FILES
 1) system and project includes
 2) needed interfaces from external units
 3) internal and external interfaces from this unit
==================================================================================================*/
#include "Mcu_Cfg.h"
#include "Reg_eSys_LPU.h"
#include "Soc_Ips.h"


/*==================================================================================================
                               SOURCE FILE VERSION INFORMATION
==================================================================================================*/

#define MCU_LPU_TYPES_VENDOR_ID                     43
#define MCU_LPU_TYPES_AR_RELEASE_MAJOR_VERSION      4
#define MCU_LPU_TYPES_AR_RELEASE_MINOR_VERSION      2
#define MCU_LPU_TYPES_AR_RELEASE_REVISION_VERSION   2
#define MCU_LPU_TYPES_SW_MAJOR_VERSION              1
#define MCU_LPU_TYPES_SW_MINOR_VERSION              0
#define MCU_LPU_TYPES_SW_PATCH_VERSION              0


/*==================================================================================================
                                      FILE VERSION CHECKS
==================================================================================================*/
/* Check if source file and Mcu_Cfg header file are from the same vendor */
#if (MCU_LPU_TYPES_VENDOR_ID != MCU_CFG_VENDOR_ID)
    #error "Mcu_LPU_Types.h and Mcu_Cfg.h have different vendor ids"
#endif
/* Check if source file and Mcu_Cfg header file are of the same Autosar version */
#if ((MCU_LPU_TYPES_AR_RELEASE_MAJOR_VERSION != MCU_CFG_AR_RELEASE_MAJOR_VERSION) || \
     (MCU_LPU_TYPES_AR_RELEASE_MINOR_VERSION != MCU_CFG_AR_RELEASE_MINOR_VERSION) || \
     (MCU_LPU_TYPES_AR_RELEASE_REVISION_VERSION != MCU_CFG_AR_RELEASE_REVISION_VERSION) \
    )
    #error "AutoSar Version Numbers of Mcu_LPU_Types.h and Mcu_Cfg.h are different"
#endif
/* Check if source file and Mcu_Cfg header file are of the same Software version */
#if ((MCU_LPU_TYPES_SW_MAJOR_VERSION != MCU_CFG_SW_MAJOR_VERSION) || \
     (MCU_LPU_TYPES_SW_MINOR_VERSION != MCU_CFG_SW_MINOR_VERSION) || \
     (MCU_LPU_TYPES_SW_PATCH_VERSION != MCU_CFG_SW_PATCH_VERSION) \
    )
    #error "Software Version Numbers of Mcu_LPU_Types.h and Mcu_Cfg.h are different"
#endif

/* Check if source file and Reg_eSys_LPU header file are from the same vendor */
#if (MCU_LPU_TYPES_VENDOR_ID != REG_ESYS_LPU_VENDOR_ID)
    #error "Mcu_LPU_Types.h and Reg_eSys_LPU.h have different vendor ids"
#endif
/* Check if source file and Reg_eSys_LPU header file are of the same Autosar version */
#if ((MCU_LPU_TYPES_AR_RELEASE_MAJOR_VERSION != REG_ESYS_LPU_AR_RELEASE_MAJOR_VERSION) || \
     (MCU_LPU_TYPES_AR_RELEASE_MINOR_VERSION != REG_ESYS_LPU_AR_RELEASE_MINOR_VERSION) || \
     (MCU_LPU_TYPES_AR_RELEASE_REVISION_VERSION != REG_ESYS_LPU_AR_RELEASE_REVISION_VERSION) \
    )
    #error "AutoSar Version Numbers of Mcu_LPU_Types.h and Reg_eSys_LPU.h are different"
#endif
/* Check if source file and Reg_eSys_LPU header file are of the same Software version */
#if ((MCU_LPU_TYPES_SW_MAJOR_VERSION != REG_ESYS_LPU_SW_MAJOR_VERSION) || \
     (MCU_LPU_TYPES_SW_MINOR_VERSION != REG_ESYS_LPU_SW_MINOR_VERSION) || \
     (MCU_LPU_TYPES_SW_PATCH_VERSION != REG_ESYS_LPU_SW_PATCH_VERSION) \
    )
    #error "Software Version Numbers of Mcu_LPU_Types.h and Reg_eSys_LPU.h are different"
#endif

/* Check if current file and Soc_Ips header file are of the same version */
#ifndef DISABLE_MCAL_INTERMODULE_ASR_CHECK
    #if ((MCU_LPU_TYPES_AR_RELEASE_MAJOR_VERSION != SOC_IPS_AR_RELEASE_MAJOR_VERSION) || \
         (MCU_LPU_TYPES_AR_RELEASE_MINOR_VERSION != SOC_IPS_AR_RELEASE_MINOR_VERSION) \
        )
        #error "AutoSar Version Numbers of Mcu_LPU_Types.h and Soc_Ips.h are different"
    #endif
#endif


/*==================================================================================================
*                                          CONSTANTS
==================================================================================================*/

/*==================================================================================================
                                       DEFINES AND MACROS
==================================================================================================*/

#define LPU_ENABLED_CLOCKS_MASK32        (LPU_RUN_CF_SXOSC_ON_MASK32 | LPU_RUN_CF_SIRC_ON_MASK32 | \
                                            LPU_RUN_CF_FXOSC_ON_MASK32 | LPU_RUN_CF_FIRC_ON_MASK32 \
                                         )
                                            
/***********************************************************/
/*                           LPU_RUN_CF                    */
/***********************************************************/
#define LPU_RUN_CF_CAN0_NOT_SUPPORTED_U32            ((uint32)0x00000000U)
#define LPU_RUN_CF_CAN0_SUPPORTED_U32                ( LPU_RUN_CF_CAN0_CONT_MASK32 )

#define LPU_RUN_CF_EXIT_TO_LPU_RUN_U32               ((uint32)0x00000000U)
#define LPU_RUN_CF_EXIT_TO_DRUN_U32                  ( LPU_RUN_CF_DIRECT_DRUN_MASK32 )

#define LPU_RUN_CF_SYS_CLK_SEL_FIRC_U32              ((uint32)0x00000000U)
#define LPU_RUN_CF_SYS_CLK_SEL_FXOSC_U32             ( LPU_RUN_CF_SYS_CLK_SEL_MASK32 )

#define LPU_RUN_CF_NO_CORE_SLEEP_U32                ((uint32)0x00000000U)
#define LPU_RUN_CF_CORE_SLEEP_U32                   ( LPU_RUN_CF_LPU_SLEEP_MASK32 )

#define LPU_RUN_CF_SXOSC_OFF_U32                    ((uint32)0x00000000U)
#define LPU_RUN_CF_SXOSC_ON_U32                     ( LPU_RUN_CF_SXOSC_ON_MASK32 )

#define LPU_RUN_CF_SIRC_OFF_U32                    ((uint32)0x00000000U)
#define LPU_RUN_CF_SIRC_ON_U32                     ( LPU_RUN_CF_SIRC_ON_MASK32 )

#define LPU_RUN_CF_FXOSC_OFF_U32                    ((uint32)0x00000000U)
#define LPU_RUN_CF_FXOSC_ON_U32                     ( LPU_RUN_CF_FXOSC_ON_MASK32 )

#define LPU_RUN_CF_FIRC_OFF_U32                    ((uint32)0x00000000U)
#define LPU_RUN_CF_FIRC_ON_U32                     ( LPU_RUN_CF_FIRC_ON_MASK32 )

/***********************************************************/
/*                           LPU_STOP_CF                   */
/***********************************************************/

#define LPU_STOP_CF_SXOSC_OFF_U32                    ((uint32)0x00000000U)
#define LPU_STOP_CF_SXOSC_ON_U32                     ( LPU_STOP_CF_SXOSC_ON_MASK32 )

#define LPU_STOP_CF_SIRC_OFF_U32                    ((uint32)0x00000000U)
#define LPU_STOP_CF_SIRC_ON_U32                     ( LPU_STOP_CF_SIRC_ON_MASK32 )

#define LPU_STOP_CF_FXOSC_OFF_U32                    ((uint32)0x00000000U)
#define LPU_STOP_CF_FXOSC_ON_U32                     ( LPU_STOP_CF_FXOSC_ON_MASK32 )

#define LPU_STOP_CF_FIRC_OFF_U32                    ((uint32)0x00000000U)
#define LPU_STOP_CF_FIRC_ON_U32                     ( LPU_STOP_CF_FIRC_ON_MASK32 )


/***********************************************************/
/*                           LPU_STANDBY_CF                */
/***********************************************************/

#define LPU_STANDBY_CF_SXOSC_OFF_U32                    ((uint32)0x00000000U)
#define LPU_STANDBY_CF_SXOSC_ON_U32                     ( LPU_STANDBY_CF_SXOSC_ON_MASK32 )

#define LPU_STANDBY_CF_SIRC_OFF_U32                    ((uint32)0x00000000U)
#define LPU_STANDBY_CF_SIRC_ON_U32                     ( LPU_STANDBY_CF_SIRC_ON_MASK32 )

#define LPU_STANDBY_CF_FXOSC_OFF_U32                    ((uint32)0x00000000U)
#define LPU_STANDBY_CF_FXOSC_ON_U32                     ( LPU_STANDBY_CF_FXOSC_ON_MASK32 )

#define LPU_STANDBY_CF_FIRC_OFF_U32                    ((uint32)0x00000000U)
#define LPU_STANDBY_CF_FIRC_ON_U32                     ( LPU_STANDBY_CF_FIRC_ON_MASK32 )

/***********************************************************/
/*                           LPU_ICR                       */
/***********************************************************/
/** @violates @ref MCU_LPU_TYPES_h_REF_1 MISRA 2004 Advisory Rule 19.7, Function-like macro defined.*/
#define LPU_ICR_INT_ENABLE(value)                     ( ((value) & LPU_ICR_RWBITS_MASK32 ) | LPU_ICR_RESBITS_MASK32 )

#define LPU_ICR_MRIG_INT_DIS_U32                    ((uint32)0x00000000U)
#define LPU_ICR_MRIG_INT_EN_U32                     ( LPU_ICR_LPU_MRIG_E_MASK32 )

#define LPU_ICR_NEM_INT_DIS_U32                    ((uint32)0x00000000U)
#define LPU_ICR_NEM_INT_EN_U32                     ( LPU_ICR_LPU_NEM_E_MASK32 )

/***********************************************************/
/*                           LPU_MDIS                      */
/***********************************************************/
#define LPU_MDIS_EMIOS_0_CLK_EN_U32                 ((uint32)0x00000000U)
#define LPU_MDIS_EMIOS_0_CLK_DIS_U32                ( LPU_MDIS_eMIOS_0_MASK32 )

#define LPU_MDIS_EMIOS_2_CLK_EN_U32                 ((uint32)0x00000000U)
#define LPU_MDIS_EMIOS_2_CLK_DIS_U32                ( LPU_MDIS_eMIOS_2_MASK32 )

#define LPU_MDIS_CMP_2_CLK_EN_U32                 ((uint32)0x00000000U)
#define LPU_MDIS_CMP_2_CLK_DIS_U32                ( LPU_MDIS_CMP_2_MASK32 )

#define LPU_MDIS_CMP_1_CLK_EN_U32                 ((uint32)0x00000000U)
#define LPU_MDIS_CMP_1_CLK_DIS_U32                ( LPU_MDIS_CMP_1_MASK32 )

#define LPU_MDIS_CMP_0_CLK_EN_U32                 ((uint32)0x00000000U)
#define LPU_MDIS_CMP_0_CLK_DIS_U32                ( LPU_MDIS_CMP_0_MASK32 )

#define LPU_MDIS_MEMU_1_CLK_EN_U32                 ((uint32)0x00000000U)
#define LPU_MDIS_MEMU_1_CLK_DIS_U32                ( LPU_MDIS_MEMU_1_MASK32 )

#define LPU_MDIS_BCTU_CLK_EN_U32                 ((uint32)0x00000000U)
#define LPU_MDIS_BCTU_CLK_DIS_U32                ( LPU_MDIS_BCTU_MASK32 )

#define LPU_MDIS_CAN0_CLK_EN_U32                 ((uint32)0x00000000U)
#define LPU_MDIS_CAN0_CLK_DIS_U32                ( LPU_MDIS_CAN0_MASK32 )

#define LPU_MDIS_LIN_0_CLK_EN_U32                 ((uint32)0x00000000U)
#define LPU_MDIS_LIN_0_CLK_DIS_U32                ( LPU_MDIS_LIN_0_MASK32 )

#define LPU_MDIS_SPI_0_CLK_EN_U32                 ((uint32)0x00000000U)
#define LPU_MDIS_SPI_0_CLK_DIS_U32                ( LPU_MDIS_SPI_0_MASK32 )

#define LPU_MDIS_ADC_0_CLK_EN_U32                 ((uint32)0x00000000U)
#define LPU_MDIS_ADC_0_CLK_DIS_U32                ( LPU_MDIS_ADC_0_MASK32 )

/*==================================================================================================
*                                             ENUMS
==================================================================================================*/

typedef enum
{
    MCU_LPU_DRUN_MODE       = 0x3U,   /**< @brief DRUN Mode. */
    MCU_LPU_RUN_MODE        = 0xBU,   /**< @brief LPU Run Mode. */
    MCU_LPU_STOP_MODE       = 0xCU,   /**< @brief LPU Stop Mode. */
    MCU_LPU_STANDBY_MODE    = 0xEU    /**< @brief LPU Standby Mode. */
} Mcu_LpuModeType;

/*==================================================================================================
*                                STRUCTURES AND OTHER TYPEDEFS
==================================================================================================*/

/**
* @brief            Definition of a MCU LPU mode section in the configuration structure.
* @details          Specifies the system behaviour during the selected target mode.
*                   Data set and configured by Mcu_SetMode call.
*/
typedef struct
{
    VAR( Mcu_ModeType, MCU_VAR) Mcu_LowPowerModeConfigId;  /**< @brief The ID for LPU Mode configuration. */
    VAR( Mcu_LpuModeType, MCU_VAR) Mcu_eLowPowerMode;       /**< @brief The Low Power Mode name (code). */
    VAR( uint32, MCU_VAR) u32LpuModeParams;                 /**< @brief Configuration of LPU_xxx_CF register */
    VAR( uint32, MCU_VAR) u32LpuInterrupts;                 /**< @brief Configuration for LPU_ICR (interrupt masking). */
    VAR( uint32, MCU_VAR) u32LpuModuleDisable;              /**< @brief Configuration for LPU_MDIS. */
} Mcu_LPU_LowPowerModeConfigType;

/*==================================================================================================
*                                GLOBAL VARIABLE DECLARATIONS
==================================================================================================*/


/*==================================================================================================
*                                    FUNCTION PROTOTYPES
==================================================================================================*/


#ifdef __cplusplus
}
#endif

#endif /* MCU_LPU_TYPES_H */

/** @} */
